# decent-cpp #

A [decent](https://github.com/decent-chat/decent) server implementation in C++,
using [eidheim/Simple-Web-Server](https://github.com/eidheim/Simple-Web-Server),
[eidheim/Simple-WebSocket-Server](https://github.com/eidheim/Simple-WebSocket-Server),
and SQLite3.

## Why? ##

Node.js is bloated and slow. This server is designed to be `blazingly fast`,
`fearlessly concurrent`, and `guarantee data safety`.

## Building ##

Dependencies (install with your favorite package manager)
 - GNU Readline >=7.0
 - SQLite3 >=3.19.3
 - libsodium, some version xd
 - Boost >=1.54
 - OpenSSL, some version xd

Older versions of dependencies will probably still work, but it's untested.

```
git clone --recursive https://notabug.org/haskal/decent-cpp.git
cd decent-cpp
mkdir build
cd build
cmake ..
make
```

### Running ###

```
./decent-cpp
```

### Windows ###

Use MSYS MinGW64, and use `cmake -G"MSYS Makefiles" ..`

## Status ##

### Currently Mega Unstable™, do not use! ###

Items of the [decent api](https://decent-chat.github.io/decent/api.html) that
are currently implemented:

### HTTP Endpoints ###

| Status | Endpoint                                                            |
| :----: | ------------------------------------------------------------------- |
| DONE   | Retrieve server version [GET /api]                                  |
| DONE   | Retrieve all settings [GET /api/settings]                           |
| DONE   | Modify settings [PATCH /api/settings]                               |
| WIP    | Upload an image [POST /api/upload-image]                            |
| WIP    | List emotes [GET /api/emotes]                                       |
| WIP    | Add a new emote [POST /api/emotes]                                  |
| WIP    | View an emote [GET /api/emotes/:shortcode]                          |
| WIP    | Delete an existing emote [DELETE /api/emotes/:shortcode]            |
| DONE   | Fetch the current user’s sessions [GET /api/sessions]               |
| DONE   | Login [POST /api/sessions]                                          |
| DONE   | Fetch session details [GET /api/sessions/:id]                       |
| DONE   | Logout [DELETE /api/sessions/:id]                                   |
| DONE   | Send a message [POST /api/messages]                                 |
| DONE   | Retrieve a message [GET /api/messages/:id]                          |
| WIP    | Edit a message [PATCH /api/messages/:id]                            |
| WIP    | Delete a message [DELETE /api/messages/:id]                         |
| DONE   | Get list of channels [GET /api/channels]                            |
| DONE   | Create a channel [POST /api/channels]                               |
| DONE   | Retrieve a channel [GET /api/channels/:id]                          |
| DONE   | Rename a channel [PATCH /api/channels/:id]                          |
| DONE   | Delete a channel [DELETE /api/channels/:id]                         |
| DONE   | Mark a channel as read [POST /api/channels/:id/mark-read]           |
| DONE   | Get messages in channel [GET /api/channels/:id/messages]            |
| DONE   | Update channel-specific role permissions [PATCH /api/channels/:id/role-permissions] |
| DONE   | Get channel-specific role permissions [GET /api/channels/:id/role-permissions] |
| WIP    | Retrieve all pinned messages [GET /api/channels/:id/pins]           |
| WIP    | Pin a message [POST /api/channels/:id/pins]                         |
| WIP    | Unpin a message [DELETE /api/channels/:channelID/pins/:messageID]   |
| DONE   | Fetch users [GET /api/users]                                        |
| DONE   | Register (create new user) [POST /api/users]                        |
| DONE   | Retrieve a user by ID [GET /api/users/:id]                          |
| DONE   | List mentions of a user [GET /api/users/:id/mentions]               |
| WIP    | Get a user's permissions [GET /api/users/:id/permissions]           |
| WIP    | Update user details [PATCH /api/users/:id]                          |
| WIP    | Delete a user [DELETE /api/users/:id]                               |
| WIP    | Check if a username is available [GET /api/username-available/:username] |
| DONE   | List roles [GET /api/roles]                                         |
| DONE   | Add a new role [POST /api/roles]                                    |
| DONE   | Update a role [PATCH /api/roles/:id]                                |
| DONE   | Delete a role [DELETE /api/emotes/:id]                              |

### Websocket events ###

| Status | Event                                                               |
| :----: | ------------------------------------------------------------------- |
| DONE   | pingdata                                                            |
| DONE   | pongdata                                                            |
| DONE   | server-settings/update                                              |
| DONE   | message/new                                                         |
| WIP    | message/edit                                                        |
| WIP    | message/delete                                                      |
| WIP    | channel/new                                                         |
| PARTIAL| channel/update                                                      |
| WIP    | channel/pins/add                                                    |
| WIP    | channel/pins/remove                                                 |
| WIP    | channel/delete                                                      |
| WIP    | user/new                                                            |
| WIP    | user/delete                                                         |
| DONE   | user/online                                                         |
| DONE   | user/offline                                                        |
| WIP    | user/update                                                         |
| DONE   | user/mentions/add                                                   |
| WIP    | user/mentions/remove                                                |
| WIP    | emote/new                                                           |
| WIP    | emote/delete                                                        |
| DONE   | role/new                                                            |
| DONE   | role/update                                                         |
| DONE   | role/delete                                                         |

### Sample Text ###

Donate tendies
